var gl_material_vue_vm_list_html = $('#material_vue_vm_list').html();
var pageParam = null;

$(function() {
	$('#vue_vm_list div').hide();
	
	var pageParamStr = $.url().param('pageParam');
	pageParam = JSON.parse(pageParamStr);
	var loginedUser = getLoginedUser();
	pageParam.createId = loginedUser.staffId;
	pageParam.createName = loginedUser.staffName;
	//pageParam.createTime = getDate();
	showParamInfo(pageParam);
	findAll();
});

function showParamInfo(pageParam) {
	if($('#vue_vm_list').length==0) {return;}
	$('#vue_vm_list div').hide();
	$('#vue_vm_list').html(gl_vue_vm_list_html);
	
	new Vue({
		el: '#vue_vm_list',
		data: {
			todos: [pageParam]
		}
	});
	
	$('#vue_vm_list div').show();
}

function findAll() {
	if($('#material_vue_vm_list').length==0) {return;}
	$('#material_vue_vm_list div').hide();

	findAll_basic(path+'/leaseSupplies/findAll', function(response) {
		$('#material_vue_vm_list').html(gl_material_vue_vm_list_html);
		
		new Vue({
			el: '#material_vue_vm_list',
			data: {
				todos: response.data
			},
			methods: {
				onClickLeaseSuppliesRadiobox:function(todo) {
					var leaseSuppliesId = $('input:radio[name="leaseSuppliesId"]:checked').val();
					if(leaseSuppliesId==todo.leaseSuppliesId) {
						pageParam.leaseSuppliesId = todo.leaseSuppliesId;
						pageParam.suppliesName = todo.suppliesName;
						pageParam.brand = todo.brand;
						pageParam.model = todo.model;
						pageParam.pledge = todo.cashPledge;
						pageParam.rent = todo.rent;
						pageParam.stockNumber = todo.stockNumber;
						pageParam.status = todo.status;
					}
				},
				getImageFullPath: function(iconUrl) {
					return imagePath + '/' + iconUrl;
				}
			}
		});
		
		$('#material_vue_vm_list div').show();
	});
}

function goNextPage() {
	var url = '5-1-1ynrent-2.html?pageParam=' + encodeURIComponent(JSON.stringify(pageParam));
	window.open(url);
}

function goNextPageOutSide() {
	var url = '5-1-2ywrent-2.html?pageParam=' + encodeURIComponent(JSON.stringify(pageParam));
	window.open(url);
}

function deleteBatch() {
	deleteBatch_basic(path+'/lease/deleteBatch');
}
